/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.modele;

import client.modele.InterfaceModele;
import Exceptions.InputAnnuiteException;
import Exceptions.InputChoixException;
import Exceptions.InputMontantException;
import Exceptions.InputNbAnException;
import Exceptions.InputTxInteretException;
import exception.CommunicationException;
import exception.CommunicationResponseApplicationException;
import exception.CommunicationResponseException;
import exception.ReadingObjectException;

/**
 *
 * @author KB

 */
public class ApplicationClient implements InterfaceModele {

    private InterfaceProtocoleClient protocole;

    public ApplicationClient() {
    }

    public ApplicationClient(InterfaceProtocoleClient _protocole) {
        protocole = _protocole;
    }

    @Override
    public double envoyerDemandeAnnuites(double montant, double txInterets, int nbAnnuite) throws CommunicationResponseApplicationException,
            InputAnnuiteException, InputChoixException,
            InputTxInteretException, InputMontantException,
            InputMontantException, InputNbAnException,
            ReadingObjectException {
        try {
            protocole.envoyerDemandeAnnuites(montant, txInterets, nbAnnuite);
            return protocole.recevoirReponse();
        } catch (CommunicationResponseException cre) {
            throw new CommunicationResponseApplicationException();
        }

    }

    @Override
    public double envoyerDemandeNbAnnees(double montant, double txInterets, double annuite) throws CommunicationResponseApplicationException, InputAnnuiteException, InputChoixException,
            InputTxInteretException, InputMontantException,
            InputMontantException, InputNbAnException, ReadingObjectException {
        try {
            protocole.envoyerDemandeNbAnnees(montant, txInterets, annuite);
            return protocole.recevoirReponse();
        } catch (CommunicationResponseException cre) {
            throw new CommunicationResponseApplicationException();
        }

    }
}
